#include "depotstringlistmodel.h"
#include <QDebug>

int depotStringListModel::rowCount(const QModelIndex &parent) const
{
    qDebug()<<"ROW_COUNT";
    return strList.count();
}

QVariant depotStringListModel::data(const QModelIndex &index, int role) const
{
    qDebug()<<"DATA: "<<index<<" : "<<role;
    if(!index.isValid())
        return QVariant();

    if(index.row()>=strList.count())
        return QVariant();

    if(role==Qt::DisplayRole || role==Qt::EditRole)
        return strList.at(index.row());

    return QVariant();
}

QVariant depotStringListModel::headerData(int section, Qt::Orientation orientation, int role) const
{
    if (role != Qt::DisplayRole)
        return QVariant();

    if (orientation == Qt::Horizontal)
        return QString("Column %1").arg(section);
    else
        return QString("Row %1").arg(section);
}

/*void depotStringListModel::setStringList(const QStringList &list)
{
    strList=list;
}

QStringList depotStringListModel::getStringList()const
{
    return strList;
}*/

Qt::ItemFlags depotStringListModel::flags(const QModelIndex &index) const
{
    qDebug()<<"Setting flag";
    if(!index.isValid())
        return Qt::ItemIsEnabled;

    qDebug()<<"Returning flags";
    return Qt::ItemIsSelectable|Qt::ItemIsEditable;
}
/*
bool depotStringListModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
    if(!index.isValid())
        return false;

    if(role==Qt::EditRole)
    {
        strList.replace(index.row(),value.toString());
        emit dataChanged(index,index);
        return true;
    }

    return false;
}*/
